let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n177,
  i =
    (this && this.__extends) ||
    ((_n177 = function n(t, e) {
      return (_n177 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
    function (t, e) {
      function o() {
        this.constructor = t;
      }
      _n177(t, e),
        (t.prototype =
          null === e
            ? Object.create(e)
            : ((o.prototype = e.prototype), new o()));
    });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.UIItemEffect = void 0);
var r = t('UIComponent'),
  a = t('ComUtils'),
  s = t('MathUtils'),
  c = t('ResMrg'),
  l = t('TimeMrg'),
  u = t('PlayerMrg'),
  h = t('UIMrg'),
  p = t('GainCardPanel'),
  f = t('GainCardVo'),
  d = (function (t) {
    function e() {
      var e = t.call(this, cc.Canvas.instance.node) || this,
        o = e;
      return (
        cc.resources.load('Prefab/Effect/UIItemEffect', function (t, e) {
          t || o.initEffect(cc.instantiate(e));
        }),
        e
      );
    }
    return (
      i(e, t),
      (e.show = function (t, o) {
        o &&
          t &&
          (this.list.length ? this.list.shift() : new e()).showEffect(t, o);
      }),
      (e.put = function (t) {
        this.list.push(t);
      }),
      (e.prototype.initEffect = function (t) {
        (this._node = t),
          (this._imgIcon = a.default.getComponent(cc.Sprite, t, 'imgIcon')),
          (this._msTrailing = a.default.getComponent(
            cc.MotionStreak,
            t,
            'msTrailing'
          )),
          this.loadIcon(),
          this.show();
      }),
      (e.prototype.showEffect = function (t, e) {
        (this._info = t.value),
          (this._buffPt = t.entity.convertToWorldSpaceAR(cc.Vec2.ZERO)),
          (this._item = e),
          this._node && (this.loadIcon(), this.show());
      }),
      (e.prototype.loadIcon = function () {
        (this._msTrailing.stroke = 10),
          c.ResMrg.loadSpriteByAtlas(
            this._imgIcon,
            'Atlas/Battle',
            this._info.icon
          );
      }),
      (e.prototype.createPath = function () {
        var t = this._item.view.convertToWorldSpaceAR(e.mount);
        (t = this.view.convertToNodeSpaceAR(t)),
          (this._buffPt = this.view.convertToNodeSpaceAR(this._buffPt));
        var o = cc.v2(
          this._buffPt.x,
          this._buffPt.y + s.default.randomInt(200, 400)
        );
        return s.default.bezier2([this._buffPt, o, t], 20);
      }),
      (e.prototype.onShow = function () {
        t.prototype.onShow.call(this),
          (this._speed = 1e3),
          (this._path = this.createPath()),
          this.next(),
          this.view.addChild(this._node),
          l.TimeMrg.timer.add(this.update, this);
      }),
      (e.prototype.next = function () {
        var t = this._node;
        if (
          (t.setPosition(this._path[0]),
          this._path.shift(),
          this._path.length > 0)
        ) {
          var e = this._path[0];
          (this._radian = Math.atan2(e.y - t.y, e.x - t.x)),
            (this._distance = s.default.distance2(t.x, t.y, e.x, e.y));
        } else this.complete();
      }),
      (e.prototype.onUpdate = function (e) {
        t.prototype.onUpdate.call(this, e);
        var o = e * this._speed;
        (this._distance -= o),
          this._distance > 0 ? this.updateLocation(o) : this.next(),
          (this._speed *= 1.02);
      }),
      (e.prototype.onClose = function () {
        t.prototype.onClose.call(this),
          l.TimeMrg.timer.remove(this.update, this),
          (this._item = null),
          (this._info = null),
          this._node && (this._node.parent = null),
          this._weapon &&
            (this._weapon.removeFromParent(!0), (this._weapon = null)),
          e.put(this);
      }),
      (e.prototype.updateLocation = function (t) {
        var e = this._node,
          o = s.default.to(e.x, e.y, this._radian, t);
        e.setPosition(o);
      }),
      (e.prototype.complete = function () {
        (this._item.buff = this._info),
          u.PlayerMrg.ins.isNewBuff(this._info.id) &&
            h.UIMrg.show(p.GainCardPanel, new f.GainCardVo(1, this._info)),
          this.close();
      }),
      (e.mount = cc.v2(-40, 40)),
      (e.list = []),
      e
    );
  })(r.UIComponent);
(o.UIItemEffect = d), console.log('end');
module.exports = e.exports;
